package main

import (
	"fmt"
	"net/http"
	"time"

	"gitee.com/szlevin/go-vue/common/setting"
	_ "gitee.com/szlevin/go-vue/controller"
	_ "gitee.com/szlevin/go-vue/docs"
	"gitee.com/szlevin/go-vue/routers"
	"github.com/gin-gonic/gin"
)

// @title Swagger Example API
// @version 1.0
// @description This is a sample server Petstore server.
// @termsOfService http://swagger.io/terms/
// @contact.name API Support
// @contact.url http://www.swagger.io/support
// @contact.email support@swagger.io
// @license.name Apache 2.0
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
// @host petstore.swagger.io
// @BasePath /v2
func main() {
	router := routers.InitRouter()
	conf := setting.Config.Server
	s := &http.Server{
		Addr:           fmt.Sprintf(":%s", conf.Port),
		Handler:        router,
		ReadTimeout:    conf.ReadTimeout * time.Second,
		WriteTimeout:   conf.WriteTimeout * time.Second,
		MaxHeaderBytes: 1 << 20,
	}

	s.ListenAndServe()
}

// @Summary 测试接口
// @Description 描述信息
// @Success 200 {string} string    "ok"
// @Router /test [get]
func Test(ctx *gin.Context) {
	ctx.JSON(200, "ok")
}
